package fmi.chesstern.pieces.strategy;

import java.util.HashSet;
import java.util.Set;


import fmi.chesstern.game.BoardField;
import fmi.chesstern.game.GameBoardState;
import fmi.chesstern.pieces.ChessPieceColor;

public class KingStrategy implements ChessPieceStrategy {
	public Set<BoardField> getValidNewPositions(GameBoardState board, BoardField currentPosition) {
		Set<BoardField> result = new HashSet<BoardField>();
		
		ChessPieceColor color = board.getPieceAt(currentPosition).getColor();
		
		for (int i = -1; i <= 1; i++) {
			for (int j = -1; j <= 1; j++) {
				if (i != 0 || j != 0) {
					BoardField newPosition = currentPosition.offsetBy(i, j);
					
					if (StrategyUtilities.canPositionOn(board, newPosition, color)) {
						result.add(newPosition);
					}
				}
			}
		}
		
		return result;
	}
}
